class Solution(object):
    def maximumSum(self, arr):
        n = len(arr)
        if n == 1:
            return arr[0]
        last0 = arr[0]
        last1 = 0
        max_val = last0
        for i in range(1, n):
            last1 = max(last1 + arr[i], last0)
            last0 = max(last0 + arr[i], arr[i])
            max_val = max(last0, last1, max_val)
        return max_val